package com.taky.Property;

import java.util.ArrayList;

import android.content.SharedPreferences;

public class PropertyManager {

	private final static String MY_SETTING_PREFS = "mypref";
	private SharedPreferences prefs;
	private SharedPreferences.Editor edit;
	
	private ArrayList<String> cookies = new ArrayList<String>();
	
	private final static String PREF_FIELD_CLEAR = "Clear";
	private String clear;
	
	private final static String PREF_FIELD_CLEAR1 = "Clear1";
	private String clear1;

	private final static String PREF_FIELD_USER_NAME = "UserName";
	private String userName;
	
	private final static String PREF_FIELD_USER_AGE = "UserAge";
	private String userAge;
	
	private final static String PREF_FIELD_USER_SEX = "UserSex";
	private String userSex;
	
	private final static String PREF_FIELD_USER_HEIGHT = "UserHeight";
	private String userHeight;
	
	private final static String PREF_FIELD_USER_WEIGHT = "UserWeight";
	private String userWeight;
	
	private final static String PREF_FIELD_USER_AIM_WEIGHT = "UserAimWeight";
	private String userAimWeight;
	
	private final static String PREF_FIELD_USER_START_YEAR = "UserStartYear";
	private String userStartYear;
	
	private final static String PREF_FIELD_USER_START_MONTH = "UserStartMonth";
	private String userStartMonth;
	
	private final static String PREF_FIELD_USER_START_DAY = "UserStartDay";
	private String userStartDay;
	
	
	private final static String PREF_FIELD_USER_AIM_PLAY_TIME = "UserAimPlayTime";
	private String userAimPlayTime;
	
	private final static String PREF_FIELD_USER_AIM = "UserAim";
	private String userAim;
	
	
	
	private final static String PREF_FIELD_CHK_TIME = "ChkTime";
	private String chkTime ="false";
	
	private final static String PREF_FIELD_CHK_SITUP = "ChkSitup";
	private String chkSitup = "false";
	
	private final static String PREF_FIELD_CHK_HALFSITUP = "ChkHalfSitup";
	private String chkHalfSitup = "false";
	
	private final static String PREF_FIELD_JUMPROPE = "ChkJumprope";
	private String chkJumprope = "false";
	
	private final static String PREF_FIELD_LEGUP = "ChkLegup";
	private String chkLegup = "false";
	
	private final static String PREF_FIELD_SQUIRT = "ChkSquirt";
	private String chkSquirt = "false";
	
	private final static String PREF_FIELD_PUSHUP = "ChkPushup";
	private String chkPushup = "false";
	
	private final static String PREF_FIELD_RUN = "ChkRun";
	private String chkRun = "false";
	
	private final static String PREF_FIELD_CHKKCAL = "ChkKcal";
	private String chkKcal = "0.0";
	
	
	
	private static PropertyManager instance = null;
	
	public static PropertyManager getInstance() {
		if (instance == null) {
			instance = new PropertyManager();
		}
		return instance;
	}
	
	private PropertyManager() {
		prefs = MyApplication.getContext().getSharedPreferences(MY_SETTING_PREFS, 0);
		edit = prefs.edit();
	}
	
	public void setCookie(ArrayList<String> nCookies) {
		// cookies = setcookies;
		ArrayList<String> removeCookie = new ArrayList<String>();
		ArrayList<String> addCookie = new ArrayList<String>();
 		for (String nCookie : nCookies) {
			String cookie = nCookie.split(";")[0];
			String head = cookie.split("=")[0];
			for (String oCookie : cookies) {
				String ohead = oCookie.split("=")[0];
				if (head.equals(ohead)) {
					removeCookie.add(oCookie);
				}
			}
			addCookie.add(cookie);
		}
 		cookies.removeAll(removeCookie);
 		cookies.addAll(addCookie);
	}
	
	public ArrayList<String> getCookie() {
		return cookies;
	}
	
	public void setClear(String clear) {
		this.clear = clear;
		edit.putString(PREF_FIELD_CLEAR, clear);
		edit.commit();
	}
	
	public String getClear() {
		if (clear != null) {
			return clear;
		}
		clear = prefs.getString(PREF_FIELD_CLEAR, "");
		return clear;
	}
	
	public void setClear1(String clear1) {
		this.clear1 = clear1;
		edit.putString(PREF_FIELD_CLEAR1, clear1);
		edit.commit();
	}
	
	public String getClear1() {
		if (clear1 != null) {
			return clear1;
		}
		clear1 = prefs.getString(PREF_FIELD_CLEAR1, "");
		return clear1;
	}
	
	public void setUserName(String userName) {
		this.userName = userName;
		edit.putString(PREF_FIELD_USER_NAME, userName);
		edit.commit();
	}
	
	public String getUserName() {
		if (userName != null) {
			return userName;
		}
		userName = prefs.getString(PREF_FIELD_USER_NAME, "");
		return userName;
	}
	
	public void setUserAge(String userAge) {
		this.userAge = userAge;
		edit.putString(PREF_FIELD_USER_AGE, userAge);
		edit.commit();
	}
	
	public String getUserAge() {
		if (userAge != null) {
			return userAge;
		}
		userAge = prefs.getString(PREF_FIELD_USER_AGE, "");
		return userAge;
	}
	
	public void setUserSex(String userSex) {
		this.userSex = userSex;
		edit.putString(PREF_FIELD_USER_SEX, userSex);
		edit.commit();
	}
	
	public String getUserSex() {
		if (userSex != null) {
			return userSex;
		}
		userSex = prefs.getString(PREF_FIELD_USER_SEX, "");
		return userSex;
	}
	
	public void setUserHeight(String userHeight) {
		this.userHeight = userHeight;
		edit.putString(PREF_FIELD_USER_HEIGHT, userHeight);
		edit.commit();
	}
	
	public String getUserHeight() {
		if (userHeight != null) {
			return userHeight;
		}
		userHeight = prefs.getString(PREF_FIELD_USER_HEIGHT, "");
		return userHeight;
	}
	
	public void setUserWeight(String userWeight) {
		this.userWeight = userWeight;
		edit.putString(PREF_FIELD_USER_WEIGHT, userWeight);
		edit.commit();
	}
		
	public String getUserWeight() {
		if (userWeight != null) {
			return userWeight;
		}
		userWeight = prefs.getString(PREF_FIELD_USER_WEIGHT, "");
		return userWeight;
	}
	public void setUserAimWeight(String userAimWeight) {
		this.userAimWeight = userAimWeight;
		edit.putString(PREF_FIELD_USER_SEX, userAimWeight);
		edit.commit();
	}
	
	public String getUserAimWeight() {
		if (userAimWeight != null) {
			return userAimWeight;
		}
		userAimWeight = prefs.getString(PREF_FIELD_USER_AIM_WEIGHT, "");
		return userAimWeight;
	}
	
	public void setUserStartYear(String userStartYear) {
		this.userStartYear = userStartYear;
		edit.putString(PREF_FIELD_USER_START_YEAR, userStartYear);
		edit.commit();
	}
	
	public String getUserStartYear() {
		if (userStartYear != null) {
			return userStartYear;
		}
		userStartYear = prefs.getString(PREF_FIELD_USER_START_YEAR, "");
		return userStartYear;
	}
	
	public void setUserStartMonth(String userStartMonth) {
		this.userStartMonth = userStartMonth;
		edit.putString(PREF_FIELD_USER_START_MONTH, userStartMonth);
		edit.commit();
	}
	
	public String getUserStartMonth() {
		if (userStartMonth != null) {
			return userStartMonth;
		}
		userStartMonth = prefs.getString(PREF_FIELD_USER_START_MONTH, "");
		return userStartMonth;
	}
	
	public void setUserStartDay(String userStartDay) {
		this.userStartDay = userStartDay;
		edit.putString(PREF_FIELD_USER_START_DAY, userStartDay);
		edit.commit();
	}
	
	public String getUserStartDay() {
		if (userStartDay != null) {
			return userStartDay;
		}
		userStartDay = prefs.getString(PREF_FIELD_USER_START_DAY, "");
		return userStartDay;
	}
	
	public void setUserAimPlayTime(String userAimPlayTime) {
		this.userAimPlayTime = userAimPlayTime;
		edit.putString(PREF_FIELD_USER_AIM_PLAY_TIME, userAimPlayTime);
		edit.commit();
	}
	
	public String getUserAimPlayTime() {
		if (userAimPlayTime != null) {
			return userAimPlayTime;
		}
		userAimPlayTime = prefs.getString(PREF_FIELD_USER_AIM_PLAY_TIME, "");
		return userAimPlayTime;
	}
	
	public void setUserAim(String userAim) {
		this.userAim = userAim;
		edit.putString(PREF_FIELD_USER_AIM, userAim);
		edit.commit();
	}
	
	public String getUserAim() {
		if (userAim != null) {
			return userAim;
		}
		userAim = prefs.getString(PREF_FIELD_USER_AIM, "");
		return userAim;
	}
	
	
	public void setChkTime(String chkTime) {
		this.chkTime = chkTime;
		edit.putString(PREF_FIELD_CHK_TIME, chkTime);
		edit.commit();
	}
	
	public String getChkTime() {
		if (chkTime != null) {
			return chkTime;
		}
		chkTime = prefs.getString(PREF_FIELD_CHK_TIME, "");
		return chkTime;
	}
	
	
	
	
	
	
	
	
	
	
	
	
	public void setChkSitup(String chkSitup) {
		this.chkSitup = chkSitup;
		edit.putString(PREF_FIELD_CHK_SITUP, chkSitup);
		edit.commit();
	}
	
	public String getChkSitup() {
		if (chkSitup != null) {
			return chkSitup;
		}
		chkSitup = prefs.getString(PREF_FIELD_CHK_SITUP, "");
		return chkSitup;
	}
	
	
	public void setChkHalSitup(String chkHalfSitup) {
		this.chkHalfSitup = chkHalfSitup;
		edit.putString(PREF_FIELD_CHK_HALFSITUP, chkHalfSitup);
		edit.commit();
	}
	
	public String getChkHalSitup() {
		if (chkHalfSitup != null) {
			return chkHalfSitup;
		}
		chkHalfSitup = prefs.getString(PREF_FIELD_CHK_HALFSITUP, "");
		return chkHalfSitup;
	}
	
	
	
	
	public void setChkJumprop(String chkJumprope) {
		this.chkJumprope = chkJumprope;
		edit.putString(PREF_FIELD_JUMPROPE, chkJumprope);
		edit.commit();
	}
	
	public String getChkJumprope() {
		if (chkJumprope != null) {
			return chkJumprope;
		}
		chkJumprope = prefs.getString(PREF_FIELD_JUMPROPE, "");
		return chkJumprope;
	}
	
	
	
	
	public void setChkLegup(String chkLegup) {
		this.chkLegup = chkLegup;
		edit.putString(PREF_FIELD_LEGUP, chkLegup);
		edit.commit();
	}
	
	public String getChkLegup() {
		if (chkLegup != null) {
			return chkLegup;
		}
		chkLegup = prefs.getString(PREF_FIELD_LEGUP, "");
		return chkLegup;
	}
	
	public void setChkSquirt(String chkSquirt) {
		this.chkSquirt = chkSquirt;
		edit.putString(PREF_FIELD_SQUIRT, chkSquirt);
		edit.commit();
	}
	
	public String getChkSquirt() {
		if (chkSquirt != null) {
			return chkSquirt;
		}
		chkSquirt = prefs.getString(PREF_FIELD_SQUIRT, "");
		return chkSquirt;
	}
	
	public void setChkPushup(String chkPushup) {
		this.chkPushup = chkPushup;
		edit.putString(PREF_FIELD_PUSHUP, chkPushup);
		edit.commit();
	}
	
	public String getChkPushup() {
		if (chkPushup != null) {
			return chkPushup;
		}
		chkPushup = prefs.getString(PREF_FIELD_PUSHUP, "");
		return chkPushup;
	}
	

	public void setChkRun(String chkRun) {
		this.chkRun = chkRun;
		edit.putString(PREF_FIELD_RUN, chkRun);
		edit.commit();
	}
	
	public String getChkRun() {
		if (chkRun != null) {
			return chkRun;
		}
		chkRun = prefs.getString(PREF_FIELD_RUN, "");
		return chkRun;
	}

	public void setChkKcal(String chkKcal) {
		this.chkKcal = chkKcal;
		edit.putString(PREF_FIELD_CHKKCAL, chkKcal);
		edit.commit();
	}
	
	public String getChkKcal() {
		if (chkKcal != null) {
			return chkKcal;
		}
		chkKcal = prefs.getString(PREF_FIELD_CHKKCAL, "");
		return chkKcal;
	}
	
	
	
}
